根据文件名称和文件夹名称进行模糊查询

public List listOfAssetNameAndFolderName(Assets assets, String dirName) {
if (assets == null || assets.getProjectUuid() == null) {
throw new IllegalStateException(“参数不能为空”);
}

    Set<String> typeList = listTypeGroupByProjectUuid(assets.getProjectUuid());
    List<String> types = new ArrayList<>();
    types.add(AssetsType.FACT);
    types.add(AssetsType.CONSTANT);
    types.add(AssetsType.GUIDED_RULE);
    types.add(AssetsType.RULE_TABLE);
    types.add(AssetsType.RULE_TREE);
    types.add(AssetsType.SCORECARD);
    types.add(AssetsType.RULE_FLOW);
    for (String type : types) {
        typeList.remove(type);
    }
    for (String type : typeList) {
        types.add(type);
    }
    int accountId = SessionHolder.currentAccount().getId();
    List<Assets> assetsList = assetsMapper.selectByAssetNameAndFolderName(assets.getProjectUuid(),
            assets.getName(),
            dirName,
            accountId ,
            SessionHolder.hasAdminPermission() );

    List dataList = new ArrayList();
    for (String type : types) {
        Map map = new HashMap();
        List<Assets> list = new ArrayList<>();
        map.put("type",type);
        for(Assets assets1 : assetsList){
            if(type.equals(assets1.getType())){
                list.add(assets1);
            }
        }
        map.put("list",list);
        dataList.add(map);
    }
    return dataList;
}
SELECT t1.id, t1.uuid, t1.create_time, t1.update_time, t1.name, t1.description, t1.type, t1.project_uuid, t1.tag, t1.is_locked FROM t_assets t1 LEFT JOIN t_folder t2 ON t1.dir_parent_id = t2.uuid LEFT JOIN t_permission t3 ON t3.identifier = t1.id WHERE t1.project_uuid = #{projectUuid} AND !t1.is_deleted AND !t2.is_deleted AND t3.type = 2 AND t3.account_id = #{accountId} AND t3.permission != "" and t1.name like concat('%',#{name},'%') and t2.dir_name like concat('%',#{dirName},'%') 因为是关联查询,所以没在文件夹的文件,在关联查询时会查不到,所以要把文件夹查询放到判断语句里面以便获取全部文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值